import Vue from "vue";
import App from "./App.vue";
import router from "./router";
import Vant from "vant";
import "vant/lib/index.css";
import { serverUrl } from "./utils/tools";
import moment from "moment";
import "./assets/main.scss";

Vue.use(Vant);

Vue.config.productionTip = false;
// 事件总线 用来解决购物车角标显示问题
Vue.prototype.$eventBus = new Vue();

//全局过滤器  过滤图片地址
Vue.filter("imgUrl", function(v) {
  if (v) {
    if (v.startsWith("http")) {
      return v;
    }
    return serverUrl + v;
  }

  return "https://img0.baidu.com/it/u=1389506498,1990831843&fm=26&fmt=auto&gp=0.jpg";
});
// 事件格式化过滤
Vue.filter("time", function(v) {
  return moment(v).format("YYYY-MM-DD HH:MM:SS");
});

new Vue({
  router,
  render: (h) => h(App),
}).$mount("#app");
